
import java.io.PrintWriter;

class VariableDeclaration extends Declaration {

	private Node type_;
	private Node type2_;
	private String name_;

	public VariableDeclaration(Node t, String n) {
		type_ = t;
		name_ = n;
	}

	public VariableDeclaration(Node t1, String n, Node t2) {
		type_ = t1;
		name_ = n;
		type2_ = t2;
	}

	@Override
	public void print(PrintWriter pw) {
		pw.println("Nonde name : VariableDeclaration. Var name is: " + name_);
		if (type2_ != null) {
			type2_.print(pw);
		}
		type_.print(pw);
	}
	
	public String translate(PrintWriter pw, String condition) {
		String strSimpleType = "";
		if(condition == null || !condition.equals("for")){
			strSimpleType = type_.translate(pw, "private ");
		}
		pw.print( name_ );
		if (type2_!=null)
		{
			pw.print("=");
			type2_.translate(pw, null);
		}
		
		if(condition == null || !condition.equals("for")){
		        pw.println(";");
			pw.println( "public void set" + name_ + "("+ strSimpleType +" input){");
			pw.println("this."+name_+"=input;");
			pw.println("}");
			pw.println( "public void get" + name_ + "(){");
			pw.println("return this."+name_+";");
			pw.println("}");
		}
		return null;
	}

}
